﻿@model ViewModels.User.RegisterModel
@{
	ViewBag.Title = "欢迎加入";
}
<partial name="_Exam" />
<h3 class="page-header">
	<small class="d-block d-sm-inline">
		一起帮(<span class="text-primary">17bang</span>).人(<span class="text-primary">ren</span>)
	</small>
	<span>欢迎你！</span>
</h3>
<hr />
<form method="post" zyf-register-submit>
	<div class="row">
		<div class="col-md-5">
			<h5 class="pt-3 pb-3">必须填写：</h5>
			<div class="form-group">
				<label class="text-info">邀请码：（必填）</label>
				<input asp-for="InviteCode" class="form-control"
					   data-val-remote="* 邀请码错误"
					   data-val-remote-url="/api/User/CheckInvitedBy"
					   placeholder="请向邀请人获取" />
				<span asp-validation-for="InviteCode"></span>
			</div>
			<partial name="../Shared/_BySMS" />
		</div>
		<div class="offset-md-1 col-md-5">
			<h5 class="pt-3 pb-3">建议填写：</h5>
			<partial name="_Name" />
			<div class="form-group">
				<label>登录密码：</label>
				<a class="text-primary float-right" 
					href="/Pwd/Forget?@ViewContext.HttpContext.Request.GetPrepage()">重置密码</a>
				<input asp-for="Password" class="form-control" placeholder=" 不少于6个字符" />
				<span asp-validation-for="Password"></span>
			</div>
			<div class="form-group">
				<label>确认密码：</label>
				<input asp-for="ConfirmPassword" class="form-control" placeholder="和密码相同" />
				<span asp-validation-for="ConfirmPassword"></span>
			</div>
		</div>
	</div>

	<div class="form-group">
		<button type="submit" class="btn btn-primary" disabled zyf-byPhone-submit>（填写短信验证码后）提交</button>
		<label class="form-check-inline ml-3">
			<input class="form-check-input" checked name="remember" id="remember" type="checkbox" value="true">
			<label class="form-check-label" for="remember">记住我</label>
		</label>
	</div>
</form>

@section Scripts{
<script>
	$(function () {
		$('[zyf-register-submit]').submit(function (event) {
			formSubmit(event, {
				url: '/api/User/Register',
				success: function (data) {
					goPrepage("/User");
				},
				failed: function () {
					initCaptcha();
				}
			})
		})
	})

	function checkPhoneNumber(data) {
		if (!data) {
			getNumberErrorMessage().text('* 该手机号码已被注册')
				.addClass('field-validation-error')
				.show();
		} else { //后续要检查，不能省略
			getNumberErrorMessage().text('').hide();
		}
	}
</script>
}
